package truef.service.commodity.service;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import edu.zut.cs.software.base.service.GenericGenerator;
import truef.commodity.domain.ComCategory;
import truef.commodity.domain.Commodity;
import truef.service.commodity.service.ComCategoryManager;
import truef.service.commodity.service.CommodityManager;

public class CommodityEntityGenerator extends GenericGenerator{
	@Autowired
	ComCategoryManager ComCategoryManager;
	
	@Autowired
	CommodityManager CommodityManager;
	
	@Test
    public void gen_ComCategory() {
        for (int i = 0; i < 10; i++) {
            ComCategory g = new ComCategory();
            g.setName("ComCategory_" + i);
            this.ComCategoryManager.save(g);
            for (int j = 0; j < 10; j++) {
                ComCategory ComCategory = new ComCategory();
                ComCategory.setName("ComCategory_" + i + "_" + j);
                ComCategory.setParent(g);
                g = this.ComCategoryManager.save(ComCategory);
                this.gen_commodity(g);
            }
        }
    }
	
	public void gen_commodity(ComCategory g) {
		for (int i = 0; i < 2; i++) {
            Commodity u = new Commodity();
            u.setName("Commodityname_" + i);
            u.setColor("color_" + i);
            u.setComcategory(g);
            this.CommodityManager.save(u);
        }
	}

}
